package com.atguigu.yygh.Controller;

import com.atguigu.yygh.common.result.R;
import com.atguigu.yygh.common.result.Result;
import com.atguigu.yygh.model.hosp.Schedule;
import com.atguigu.yygh.service.ScheduleService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @description: TODO
 * @author: 化一帆
 * @date: 2022/12/1 13:10
 * @version: v1.0
 */
@RestController
//@CrossOrigin
@RequestMapping("/admin/hosp/schedule")
public class ScheduleController {
    @Autowired
    private ScheduleService scheduleService;

    /**
     * @description: 根据医院的编号和科室编号查询排班规则
     * @author 化一帆
     * @date 2022/12/1 13:12
     */
    @ApiOperation(value = "查询排班规则数据")
    @GetMapping("getScheduleRule/{page}/{limit}/{hoscode}/{depcode}")
    public R getScheduleRule(@PathVariable Long page,
                             @PathVariable Long limit,
                             @PathVariable String hoscode,
                             @PathVariable String depcode){
      Map<String,Object> map=scheduleService.getRuleSchedule(page,limit,hoscode,depcode);
      return R.ok().data(map);
    }

    /**
     * @description: 根据医院编号，科室信息和工作日期，查询排班详细信息
     * @author 化一帆
     * @date 2022/12/1 20:22
     */
    @ApiOperation(value = "查询排班详细信息")
    @GetMapping("getScheduleDetail/{hoscode}/{depcode}/{workDate}")
    public R getScheduleDetail(@PathVariable String hoscode,
                               @PathVariable String depcode,
                               @PathVariable String workDate) {
        List<Schedule> list = scheduleService.getDetailSchedule(hoscode,depcode,workDate);
        return R.ok().data("list",list);
    }
}
